VERSION 5.00
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Begin VB.Form frmMessage 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "openMSN"
   ClientHeight    =   6615
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   9585
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6615
   ScaleWidth      =   9585
   StartUpPosition =   3  'Windows Default
   Begin ComctlLib.StatusBar sbPanel 
      Align           =   2  'Align Bottom
      Height          =   375
      Left            =   0
      TabIndex        =   3
      Top             =   6240
      Width           =   9585
      _ExtentX        =   16907
      _ExtentY        =   661
      SimpleText      =   ""
      _Version        =   327682
      BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7} 
         NumPanels       =   1
         BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
            AutoSize        =   2
            Bevel           =   0
            TextSave        =   ""
            Object.Tag             =   ""
         EndProperty
      EndProperty
   End
   Begin VB.Timer tmTyping 
      Enabled         =   0   'False
      Interval        =   10000
      Left            =   4920
      Top             =   2160
   End
   Begin VB.CommandButton cmdSend 
      Caption         =   "Send"
      Height          =   1335
      Left            =   6360
      TabIndex        =   2
      Top             =   4800
      Width           =   1335
   End
   Begin VB.TextBox txtMessage 
      Height          =   1335
      Left            =   120
      MultiLine       =   -1  'True
      TabIndex        =   0
      Top             =   4800
      Width           =   6135
   End
   Begin MSWinsockLib.Winsock sckMessage 
      Left            =   240
      Top             =   4800
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
   End
   Begin RichTextLib.RichTextBox rtfLog 
      Height          =   4575
      Left            =   120
      TabIndex        =   1
      Top             =   120
      Width           =   7575
      _ExtentX        =   13361
      _ExtentY        =   8070
      _Version        =   393217
      BorderStyle     =   0
      Enabled         =   -1  'True
      ReadOnly        =   -1  'True
      ScrollBars      =   2
      TextRTF         =   $"frmMessage.frx":0000
   End
End
Attribute VB_Name = "frmMessage"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public SessionID As String
Public AuthString As String
Public RemoteHost As String
Public RemotePort As Integer
Public ContactName As String
Public ContactEmail As String
Public WindowID As Integer

Public Participants As Boolean

Dim messa As Integer

Dim trID_b As Integer

Function trID()
    trID_b = trID_b + 1
    trID = trID_b
End Function

Private Sub cmdSend_Click()
    If Participants = True Then
        sendMessage txtMessage, Me.WindowID
    Else
        messa = messa + 1
        ReDim Preserve savedMessages(messa)
        savedMessages(messa) = Me.WindowID & ":/:/:::r0binrules://" & txtMessage.Text
        
        Send "CAL " & trID() & " " & ContactEmail
    End If
    txtMessage = ""
End Sub

Private Sub Form_Load()
    Connect
End Sub

Public Sub Connect()
    trID_b = -1
    sckMessage.Close
    sckMessage.Connect RemoteHost, RemotePort
    Me.Caption = ContactName & " (" & ContactEmail & ")"
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Send "OUT"
End Sub

Private Sub rtfLog_Change()
    txtMessage.SetFocus
    tmTyping.Enabled = False
    sbPanel.Panels(1).Text = "Last message recieved at " & Time & ", " & Date
End Sub


Private Sub sckMessage_Connect()
    If Not SessionID = -1 Then
        Send "ANS " & trID() & " " & frmMain.txtUsername & " " & AuthString & " " & SessionID
        rtfLog.SelStart = Len(rtfLog.Text)
        rtfLog.SelIndent = 0
        rtfLog.SelText = ContactName & " (" & ContactEmail & ") has joined the conversation" & vbCrLf
        Participants = True
    Else
        Send "USR " & trID() & " " & frmMain.txtUsername & " " & AuthString
    End If
End Sub

Private Sub sckMessage_DataArrival(ByVal bytesTotal As Long)

    Dim gotString As String
    sckMessage.GetData gotString
    CParse gotString, Me.WindowID
    
End Sub

Private Sub sckMessage_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
    rtfLog.SelStart = Len(rtfLog.Text)
    rtfLog.SelIndent = 0
    rtfLog.SelText = "Error: " & Description & vbCrLf & " please reopen the message box and try again" & vbCrLf
End Sub

Sub Send(Str)
    Log "Out: " & Str
    If sckMessage.State = sckConnected Then
        sckMessage.SendData Str & vbCrLf
    End If
End Sub

Private Sub tmTyping_Timer()
    sbPanel.Panels(1).Text = Urldecode(Me.ContactName) & " has stopped typing."
    tmTyping.Enabled = False
End Sub

Private Sub txtMessage_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyReturn Then
        cmdSend.SetFocus
        cmdSend_Click
        txtMessage.SetFocus
        txtMessage = ""
        SendKeys "{backspace}"
    End If
End Sub
